package com.zsy.service.impl;

import com.zsy.mapper.StudentMapper;

import com.zsy.pojo.StudentCountOption;
import com.zsy.service.StudentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * @author: zhengsuyang
 * @Desc:
 * @create: 2025-09-11 11:38
 **/
@Service
public class StudentServiceImpl implements StudentService {

    @Autowired
    private StudentMapper studentMapper;
    /**
     * 学员学历统计
     *
     * @return
     */
    @Override
    public List<Map> getStudentDegreeData() {
       return studentMapper.getStudentDegreeData();
    }

    /**
     * 班级人数统计
     *
     * @return
     */
    @Override
    public StudentCountOption getStudentCountData() {
       List<Map> mapList = studentMapper.getStudentCountData();
        List<Object> clazzList = mapList.stream().map(dataList -> dataList.get("ClazzName")).toList();
        List<Object> totalList = mapList.stream().map(dataList -> dataList.get("total")).toList();
        return new StudentCountOption(clazzList,totalList);
    }
}
